#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void parr(const void*e1,const void*e2)
{
	return *(int*)e1 - *(int*)e2;
}
void swap( char* t1, char* t2,size_t width)
{
	int tmp=0;
	for (int i = 0;i < width;i++)
	{
		tmp = *t1;
		*t1 = *t2;
		*t2 = tmp;
		t1++;
		t2++;
	}

}
void bubble(void* base, size_t sz,size_t width, int (*pa)(const void* e1,const void* e2))
{
	int i = 0;
	for (i = 0;i < sz-1;i++)
	{
		for(int j=0;j<sz-1-i;j++)
		{
			if ((pa((char*)base + j * width, (char*)base + (j + 1) * width))>0)
			{
				swap((char*)base +j*width,(char*)base +(j+1)*width,width);
			}
		}
	}
}
int main()
{   
	int arr[] = { 1,9,8,5,4,6,7,2,3,0 };
	bubble (arr, sizeof(arr) / sizeof(arr[0]), sizeof(arr[0]), parr);
	for (int i = 0;i < sizeof(arr) / sizeof(arr[0]);i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}